package com.renge.eduservice.controller.homepage;

import com.renge.commonutils.R;
import com.renge.eduservice.service.EduTeacherService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * <p>
 * 讲师 前端控制器
 * </p>
 *
 * @author testjava
 * @since 2021-06-25
 */
@Api(description="前端讲师管理")
@RestController
@CrossOrigin
@RequestMapping("/eduservice/front-teacher")
public class IndexFrontTeacherController {
      @Autowired
      private EduTeacherService eduTeacherService;

    @ApiOperation(value = "分页查询讲师列表")
    @GetMapping("/page/{current}/{pagesize}")
    public R findAllByPage(@ApiParam(name = "current",value = "当前页",required = true)
                           @PathVariable("current")Integer current,
                           @ApiParam(name = "pagesize",value = "每页数据量",required = true)
                           @PathVariable("pagesize")Integer pagesize){
        Map<String,Object> teacherMap=eduTeacherService.indexFindAllByPage(current,pagesize);
        return R.ok().data("teacherMap",teacherMap);
    }
    @ApiOperation(value = "根据讲师id查询基本信息并其下所授课程")
    @GetMapping("/teacher/{teacherId}")
    public R findTeacherById(@ApiParam(name = "teacherId",value = "讲师id",required = true)
                           @PathVariable("teacherId")String teacherId){
        Map<String,Object> teacherMap=eduTeacherService.findTeacherById(teacherId);
        return R.ok().data("teacherMap",teacherMap);
    }

}
